package cn.ex.ymcc.service.impl;

import cn.ex.ymcc.result.JSONResult;
import cn.ex.ymcc.service.ISysDicService;
import cn.ex.ymcc.util.AssertUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * @Author: ZeWangmu
 * @Date: 2022/08/16/14:47
 * @Description:  查询数据字典，通过feign调用service-system
 */
@Service
public class SysDicServiceImpl implements ISysDicService {
    @Autowired
    private SysDicFeignClient sysDicFeignClient;

    @Autowired
    private RedisTemplate<Object,Object> redisTemplate;

    /**
     * 查询数据字典存储redis
     */
    @Override
    public void initialize() {
        JSONResult sysDic = sysDicFeignClient.findSysDic();
        AssertUtil.isTrue(sysDic.isSuccess(),"初始化异常");
        Object data = sysDic.getData();
        String key = "cn.ex";
        redisTemplate.opsForValue().set(key,data);

    }
}
